using System;
using System.Collections.Generic;
using System.Text;
using GarageGames.Torque.T2D;
using GarageGames.Torque.Materials;
using GarageGames.Torque.Core;
using Microsoft.Xna.Framework;
using Xyne.Templates.PuzzlePieceTemplate;
using Xyne.Network;
using Xyne.Objects;

namespace Xyne.Regions
{
    public abstract class QueueRegion : StateEntity
    {
        private Rectangle bounds;
        private PuzzleRegion puzzleRegion;
        private float[] playerAlignmentModifiers;
        private float[] enemyAlignmentModifiers;

        protected float[] PlayerAlignmentModifiers
        {
            get { return playerAlignmentModifiers; }
        }

        protected float[] EnemyAlignmentModifiers
        {
            get { return enemyAlignmentModifiers; }
        }

        public Rectangle Bounds
        {
            get
            {
                return bounds;
            }

            set
            {
                bounds = value;
            }
            
        }

        public PuzzleRegion PuzzleRegion
        {
            get
            {
                return puzzleRegion;
            }

            set
            {
                puzzleRegion = value;
            }
        }
    

        public QueueRegion(Rectangle bounds)
        {
            EntityType = EntityType.QueueRegion;
            this.bounds = bounds;
            playerAlignmentModifiers = new float[(int)AlignmentEnum.Length];
            enemyAlignmentModifiers = new float[(int)AlignmentEnum.Length];
        }

        public virtual void Init(PuzzleRegion puzzleRegion)
        {
            this.puzzleRegion = puzzleRegion;
            for (int i = 0; i < (int)AlignmentEnum.Length; i++)
            {
                playerAlignmentModifiers[i] = 1.0f;
                enemyAlignmentModifiers[i] = 1.0f;
            }
        }

        public virtual void ModifyPlayerAlignment(AlignmentEnum alignment, float modfication)
        {
            playerAlignmentModifiers[(int)alignment] += modfication;
            if (playerAlignmentModifiers[(int)alignment] < .5f)
            {
                playerAlignmentModifiers[(int)alignment] = .5f;
            }

            if (playerAlignmentModifiers[(int)alignment] > 1.5f)
            {
                playerAlignmentModifiers[(int)alignment] = 1.5f;
            }
            
        }

        public virtual void ModifyEnemyAlignment(AlignmentEnum alignment, float modfication)
        {
            enemyAlignmentModifiers[(int)alignment] += modfication;
            if (enemyAlignmentModifiers[(int)alignment] < .5f)
            {
                enemyAlignmentModifiers[(int)alignment] = .5f;
            }

            if (enemyAlignmentModifiers[(int)alignment] > 1.5f)
            {
                enemyAlignmentModifiers[(int)alignment] = 1.5f;
            }

        }

        public abstract PlayerPieces GetNextPiece();

    }
}
